//
//  YQSSHeadView.m
//  industry
//
//  Created by 王雅强 on 2021/1/29.
//  Copyright © 2021 Haier. All rights reserved.
//

#import "YQSSHeadView.h"

typedef void(^SegmentSelect)(NSInteger);

@interface YQSSHeadView()<RPTaggedNavViewDelegate>

@property (nonatomic, copy) SegmentSelect segmentSelectBlock;
@end

@implementation YQSSHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.segment];
        [self addSubview:self.searchBarView];
        [self makeConstraints];
    }
    return self;
}

- (void)makeConstraints {
    [self.segment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(30);
        make.top.equalTo(self).offset(STATUSBAR_HEIGHT + 30);
        make.size.mas_equalTo(CGSizeMake(140, 35));
    }];
    
    [self.searchBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-10);
        make.left.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
    }];
    

}

#pragma mark - Public

-(void)setSegmentSelectBlock:(void (^)(NSInteger index))segmentSelectBlock{
    _segmentSelectBlock = segmentSelectBlock;
}

//- (void)loadSceduleStatusDataArr:(NSArray *)datasArr {
//    self.statusArr = datasArr;
//    [_statuView loadItemsDataArr:datasArr];
//}

#pragma mark - RPTaggedNavViewDelegate
- (void)haveSelectedIndex:(NSInteger)index {
    NSString * str = [NSString stringWithFormat:@"搜索%@信息",self.segment.dataArr[index]];
    [_searchBarView changeTextFieldPlaceHolder:str];
    
    if (self.segmentSelectBlock) {
        self.segmentSelectBlock(index);
    }
    
    }

#pragma mark - XLScheduleStatusViewDelegate
//- (void)scheduleStatusSelectIndex:(NSInteger)index {
//    if (self.delegate && [self.delegate respondsToSelector:@selector(statusChangeIndex:)]) {
//        [self.delegate statusChangeIndex:index];
//    }
//}

#pragma mark - setter/getter
- (LLRPSegment *)segment {
    if (!_segment) {
        _segment = [[LLRPSegment alloc] initWithFrame:CGRectMake(0, 0, 140, 35)];
        _segment.backgroundColor = [UIColor whiteColor];
        _segment.delegate = self;
        _segment.sliderColor = [UIColor blueBgColor];
        _segment.tagTextFont_normal = [UIFont fontOfPingFangSCRegularWithSize:14];
        _segment.tagTextFont_selected = [UIFont fontOfPingFangSCSemiboldWithSize:17];
        _segment.tagTextColor_normal = [UIColor grayFontColor];
        _segment.tagTextColor_selected = [UIColor blackFontColor];
        _segment.sliderW = 14;
        _segment.sliderH = 4;
    }
    return _segment;
}

- (YQSearchBarView *)searchBarView {
    if (!_searchBarView) {
        _searchBarView = [[YQSearchBarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
        [_searchBarView changeTextFieldPlaceHolder:@"搜索待办事项"];
    }
    return _searchBarView;
}



@end
